<template>
	<view class="index">
		<view class="item-wrapper">
			<view class="title-wrapper">
				<view class="title">
					账户信息
				</view>
			</view>
			<view class="form-wrapper">
				<view class="form-item">
					<view class="form-label">
						姓名称谓：
					</view>
					<view class="form-value">
						{{ userInfo.staffName }}
					</view>
				</view>
				<view class="form-item">
					<view class="form-label">
						手机号码：
					</view>
					<view class="form-value">
						{{ userInfo.staffTel }}
					</view>
				</view>
			</view>
		</view>
		<view class="item-wrapper">
			<view class="title-wrapper">
				<view class="title">
					接单状态
				</view>
				<view class="value" v-if="statusShow">
					<text v-if="flag">接单中</text>
					<text v-else>暂停接单</text>
					<switch style="margin-left: 10rpx;" :checked="flag" @change="switchChange" />
				</view>
				<uni-icons type="right" color="#ffffff" size="18"></uni-icons>
			</view>
		</view>
		<view class="item-wrapper">
			<view class="title-wrapper">
				<view class="title">
					经营备案
				</view>
			</view>
			<view class="form-wrapper">
				<view class="form-item">
					<view class="form-label">
						所属城市：
					</view>
					<view class="form-value">
						{{ userInfo.cityPointInfo.belongCity }}
					</view>
				</view>
				<view class="form-item">
					<view class="form-label">
						网点级别：
					</view>
					<view class="form-value">
						{{ userInfo.cityPointInfo.dotLevel == '0' ? '总仓':'自提点' }}
					</view>
				</view>
				<view class="form-item">
					<view class="form-label">
						提货点名称：
					</view>
					<view class="form-value">
						{{ userInfo.cityPointInfo.pointName }}
					</view>
				</view>
				<view class="form-item">
					<view class="form-label">
						提货点编号：
					</view>
					<view class="form-value">
						{{ userInfo.cityPointInfo.pointCode }}
					</view>
				</view>
				<view class="form-item">
					<view class="form-label">
						详细地址：
					</view>
					<view class="form-value">
						{{ userInfo.cityPointInfo.pointAddress }}
					</view>
				</view>
				<view class="form-item" @click="editPhone">
					<view class="form-label">
						客服电话：
					</view>
					<view class="form-value">
						{{ userInfo.cityPointInfo.serviceTel }}
					</view>
					<uni-icons type="right" color="#898989" size="16"></uni-icons>
				</view>
			</view>
		</view>
		<!-- <view class="item-wrapper">
			<view class="title-wrapper">
				<view class="title">
					投诉与反馈
				</view>
				<view class="value">
				</view>
				<uni-icons type="right" color="#898989" size="18"></uni-icons>
			</view>
		</view> -->
		<!-- <view class="item-wrapper">
			<view class="title-wrapper">
				<view class="title">
					规则中心
				</view>
				<view class="value">
				</view>
				<uni-icons type="right" color="#898989" size="18"></uni-icons>
			</view>
		</view> -->

		<view class="btn-wrapper" @click="logout">
			退出登录
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				statusShow: true,
				flag: false
			}
		},
		computed: {
			userInfo() {
				return this.$store.state.userInfo
			},
			cityPointInfo() {
				return this.$store.state.userInfo.cityPointInfo
			},
		},
		mounted() {
			if (this.cityPointInfo.pointStatus == '1') {
				this.flag = true;
			}
		},
		methods: {
			logout() {
				uni.showModal({
					title: '温馨提示',
					content: '是否确定退出？',
					success: (e) => {
						if (e.confirm) {
							this.$store.commit('logout', '')
							uni.reLaunch({
								url: '/pages/login/index'
							})
						}
					}
				})
			},
			editPhone() {
				if (!this.userInfo.isAdmin) return
				uni.navigateTo({
					url: '/subPage_mine/editServiceTel'
				})
			},
			async switchChange(e) {
				let content = '';
				if (!e.detail.value) {
					content = '暂停接单客户将不能在该自提点进行下单，是否继续？'
				} else {
					content = '是否恢复接单？'
				}
				this.statusShow = false;
				uni.showModal({
					title: '温馨提示',
					content: content,
					success: async (ev) => {
						if (ev.confirm) {
							this.flag = e.detail.value;
							this.statusShow = true;
							await this.$api.post('/app/pickuppoint/changeStatus', {
								id: this.userInfo.pickupPointId,
								pointStatus: e.detail.value ? 1 : 2
							})
							this.$store.commit('setUserInfo')
						} else {
							this.flag = !e.detail.value;
							this.$nextTick(() => {
								this.statusShow = true;
							})
						}
					}
				})
			}
		},
		components: {

		}
	}
</script>

<style lang="scss" scoped>
	.index {
		height: 100%;
		overflow: auto;

		.eCode-wrapper {
			background-color: #ffffff;
			margin: 10upx 0;
			padding: 40upx;


		}

		.item-wrapper {
			background-color: #ffffff;
			margin: 10upx 0upx 0 0upx;
			padding: 25upx;

			.user-info {
				.info {
					&:last-child {
						margin-top: 20upx;
					}
				}
			}


			.title-wrapper {
				display: flex;
				align-items: center;

				.icon {
					margin-right: 5upx;
				}

				.title {
					height: 34upx;
					line-height: 34upx;
					font-size: 34upx;
					color: #222222;
					padding-left: 10upx;
					border-left: 8upx solid #F26022;
				}

				.value {
					flex: 1;
					text-align: right;
					font-size: 32upx;
					color: #666666;
				}

				.input {
					flex: 1;
					text-align: right;
					font-size: 32upx;
					color: #666666;
					margin-right: 10upx;
				}
			}



			.form-wrapper {
				padding: 0 20upx;

				.form-item {
					display: flex;
					align-items: center;
					justify-content: space-between;
					font-size: 28upx;
					margin-top: 30upx;

					.form-label {
						color: #232323;
					}

					.form-value {
						color: #666666;
						flex: 1;
						text-align: right;
					}
				}
			}
		}

		.btn-wrapper {
			height: 100upx;
			background-color: #ffffff;
			margin-top: 40upx;
			margin-bottom: 100upx;
			display: flex;
			align-items: center;
			justify-content: center;
			font-size: 32upx;
			color: #222222;
		}
	}
</style>